import fetch from './fetch'
import Ls from '../utils/storage'
import { baonahao } from './env'
/**
 * 学员列表 
 * @param {String} merchant_id // 机构ID
 * @param {String} parent_id // 家长ID
 */
export function getStudentList({
  merchant_id = Ls.getItem("merchant_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  is_default,
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Goods/getStudentList',
    params: {
      data: {
        merchant_id,
        parent_id,
        is_default
      }
    }
  })
}
/**
 * 添加学员 
 * @param {String} merchant_id // 机构ID
 * @param {String} parent_id // 家长ID
 */
export function addStudent({
  merchant_id = Ls.getItem("merchant_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  student_id,
  name,
  avatar,
  sex,
  birthday,
  height,
  weight,
  clothing_size,
  shoe_size
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Goods/addStudent',
    params: {
      data: {
        merchant_id,
        parent_id,
        student_id,
        name,
        avatar,
        sex,
        birthday,
        height,
        weight,
        clothing_size,
        shoe_size
      }
    }
  })
}
// 获取默认学员
export function getDefaultStudent({
  merchant_id = Ls.getItem("merchant_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  is_default,
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Goods/getStudentList',
    params: {
      data: {
        merchant_id,
        parent_id,
        is_default
      }
    }
  })
}
/**
 * 获取校区列表
 * @param {String} merchant_id // 机构ID
 */
export function getCampusList({
  merchant_id = Ls.getItem("merchant_id"),
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Campus/getCampusList',
    params: {
      data: {
        merchant_id
      }
    }
  })
}
/**
 * 获取排课老师列表
 * @param {String} merchant_id // 机构ID
 * @param {String} platform_id // 平台ID/packey
 */
export function getGoodsTeacherList({
  merchant_id = Ls.getItem("merchant_id"),
  platform_id = Ls.getItem("platform_id")
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Campus/getGoodsTeacherList',
    params: {
      data: {
        merchant_id,
        platform_id
      }
    }
  })
}
/**
 * 考情情况
 * @param {String} merchant_id // 机构ID
 * @param {String} goods_id // 班级ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 * @param {String} project_id // 项目ID
 */
export function getAttendanceStatusList({
  merchant_id = Ls.getItem("merchant_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  student_id = Ls.getItem("childInfor").student_id,
  goods_id,
  project_id
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/teaching/Attendance/getAttendanceStatusList',
    params: {
      data: {
        student_id,
        merchant_id,
        goods_id,
        parent_id,
        project_id
      }
    }
  })
}
/**
 * 转班
 * @param {String} merchant_id // 机构ID
 * @param {String} goods_id // 班级ID
 * @param {String} student_id // 学生ID
 */
export function shiftWork({
  merchant_id = Ls.getItem("merchant_id"),
  student_id = Ls.getItem("childInfor").student_id,
  goods_id,
  curr_page,
  page_size
} = {}) {
  return fetch({
    url: '/Goods/shiftWork',
    params: {
      data: {
        student_id,
        merchant_id,
        goods_id,
        curr_page,
        page_size
      }
    }
  })
}
/**
 * 转班--获取课程列表
 * @param {String} merchant_id // 机构ID
 * @param {String} campus_id // 校区ID
 * @param {String} season_id // 季度id（以英文逗号相隔）
 * @param {String} project_id // 教师ID
 * @param {String} packages // 教师ID
 * @param {String} class_hour_minute // 课时
 * @param {String} curr_page // 页数
 * @param {String} page_size // 显示条数
 */
export function getGoodsList({
  merchant_id = Ls.getItem("merchant_id"),
  campus_id,
  season_id,
  project_id = Ls.getItem("project_id"),
  packages,
  class_hour_minute,
  curr_page,
  page_size
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Goods/getGoodsList',
    params: {
      data: {
        conditions: {
          merchant_id,
          campus_id,
          season_id,
          packages,
          class_hour_minute
        },
        project_id,
        page_infos:{
          curr_page,
          page_size
        } 
      }
    }
  })
}
/**
 * 转班--获取课程列表-套餐
 * @param {String} goods_id // 班级ID
 * @param {String} parent_id // 课时
 * @param {String} curr_page // 页数
 * @param {String} page_size // 显示条数
 */
export function getGoodsPackagesList({
  goods_id,
  parent_id = Ls.getItem("parentInfor").parent_id,
  curr_page,
  page_size
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Goods/getGoodsPackagesList',
    params: {
      data: {
        conditions: {
          goods_id,
          parent_id
        },
        page_infos:{
          curr_page,
          page_size
        } 
      }
    }
  })
}
/**
 * 获取课程详情相关内容
 * @param {String} goods_id //班级ID
 * @param {String} project_id // 教师ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 * @param {String} renew_goods_id // 续报班级ID
 */
export function getGoodsDetailInformation({
  goods_id,
  project_id = Ls.getItem("project_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  student_id = Ls.getItem("childInfor").student_id,
  renew_goods_id
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/goods/Goods/getGoodsDetailInformation',
    params: {
      data: {
        goods_id,
        project_id,
        parent_id,
        student_id,
        renew_goods_id
      }
    }
  })
}
/**
 * 转班--课次列表
 * @param {String} merchant_id // 机构ID
 * @param {String} goods_id // 班课ID
 */
export function getLessonsList({
  merchant_id = Ls.getItem("merchant_id"),
  goods_id,
} = {}) {
  return fetch({
    url: '/Goods/getLessonsList',
    params: {
      data: {
        merchant_id,
        goods_id
      }
    }
  })
}
/**
 * 赛事活动
 * @param {String} merchant_id // 机构ID
 */
export function getActivityRelatedList({
  merchant_id = Ls.getItem("merchant_id"),
  curr_page,
  page_size
} = {}) {
  return fetch({
    url: '/ActivityRelated/getActivityRelatedList',
    params: {
      data: {
        merchant_id,
        curr_page,
        page_size
      }
    }
  })
}
/**
 * 获取可请假班级
 * @param {String} merchant_id // 机构ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 */
export function getLeaveClass({
  merchant_id = Ls.getItem("merchant_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  student_id = Ls.getItem("childInfor").student_id,
} = {}) {
  return fetch({
    url: '/Leave/getLeaveClass',
    params: {
      data: {
        merchant_id,
        parent_id,
        student_id
      }
    }
  })
}
/**
 * 获取可请假班级课次
 * @param {String} merchant_id // 机构ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 * @param {String} goods_id // 班级ID
 * @param {String} sub_order_id // 子订单ID
 * @param {String} type // 类型（1、普通班课 2、艺体课）
 */
export function getLeaveClassLesson({
  merchant_id = Ls.getItem("merchant_id"),
  parent_id = Ls.getItem("parentInfor").parent_id,
  student_id = Ls.getItem("childInfor").student_id,
  goods_id,
  sub_order_id,
  type
} = {}) {
  return fetch({
    url: '/Leave/getLeaveClassLesson',
    params: {
      data: {
        merchant_id,
        parent_id,
        student_id,
        goods_id,
        sub_order_id,
        type
      }
    }
  })
}
/**
 * 添加班级请假记录
 * @param {String} merchant_id // 机构ID
 * @param {String} member_id // 会员ID
 * @param {String} created // 创建人ID==家长ID
 * @param {String} student_id // 学生ID
 * @param {String} student_name // 学员姓名
 * @param {String} brand_id // 品牌ID
 * @param {String} goods_id // 班级ID
 * @param {String} reason // 请假原因
 * @param {String} start_date // 开始时间
 * @param {String} end_date // 结束时间
 * @param {String} business_type // 业务(1:班课 2:1对1 3:艺体课 4:全日制)
 * @param {String} lesson_ids // 课次ID,多个以逗号隔开
 * @param {String} leave_dates // 请假时间,多个以逗号隔开，和请假课次一一对应
 */
export function addClassLeaveApplie({
  merchant_id = Ls.getItem("merchant_id"),
  student_id = Ls.getItem("childInfor").student_id,
  member_id = Ls.getItem("member_id"),
  created = Ls.getItem("parentInfor").parent_id,
  student_name = Ls.getItem("childInfor").student_name,
  brand_id = Ls.getItem("brand_id"),
  goods_id,
  reason,
  start_date,
  end_date,
  business_type,
  lesson_ids,
  leave_dates
} = {}) {
  return fetch({
    url: '/Leave/addClassLeaveApplie',
    params: {
      data: {
        merchant_id,
        member_id,
        created,
        student_id,
        student_name,
        brand_id,
        goods_id,
        reason,
        start_date,
        end_date,
        business_type,
        lesson_ids,
        leave_dates
      }
    }
  })
}
/**
 * 请假记录
 * @param {String} merchant_id // 机构ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 * @param {String} curr_page // 页数
 * @param {String} page_size // 显示条数
 */
export function getClassLeaveApplie({
  merchant_id = Ls.getItem("merchant_id"),
  student_id = Ls.getItem("childInfor").student_id,
  parent_id = Ls.getItem("parentInfor").parent_id,
  curr_page,
  page_size
} = {}) {
  return fetch({
    url: '/Leave/getClassLeaveApplie',
    params: {
      data: {
        merchant_id,
        parent_id,
        student_id,
        curr_page,
        page_size
      }
    }
  })
}
/**
 * 续费列表
 * @param {String} merchant_id // 机构ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 */
export function getRenewList({
  merchant_id = Ls.getItem("merchant_id"),
  student_id = Ls.getItem("childInfor").student_id,
  parent_id = Ls.getItem("parentInfor").parent_id,
} = {}) {
  return fetch({
    url: '/Goods/getRenewList',
    params: {
      data: {
        merchant_id,
        parent_id,
        student_id,
      }
    }
  })
}
/**
 * 添加订单addOrder
 * @param {String} merchant_id // 机构ID
 * @param {String} project_id // 项目ID
 * @param {String} parent_id // 家长ID
 * @param {String} student_id // 学生ID
 * @param {String} real_amount // 订单金额
 * @param {String} shopping_cart_ids // 购物车ID/商品ID
 * @param {String} type // 订单提交方式（1、购物车提交 2、商品直接购买）
 * @param {String} is_coupon // 是否使用优惠券（1、是 2、否）
 * @param {String} is_online // 是否线上出账(1:是 2:否)
 * @param {String} platform_type // 1、无请假抵扣 2、有请假抵扣
 * @param {String} renew_goods_id // 续报班级ID
 */
export function addOrder({
  merchant_id = Ls.getItem("merchant_id"),
  project_id = Ls.getItem("project_id"),
  student_id = Ls.getItem("childInfor").student_id,
  parent_id = Ls.getItem("parentInfor").parent_id,
  real_amount,
  shopping_cart_ids,
  type = 2,
  is_coupon,
  is_online,
  platform_type,
  renew_goods_id
} = {}) {
  return fetch({
    baseURL: baonahao,
    url: '/app/order/Order/addOrder',
    params: {
      data: {
        merchant_id,
        project_id,
        parent_id,
        student_id,
        real_amount,
        shopping_cart_ids,
        type,
        is_coupon,
        is_online,
        platform_type,
        renew_goods_id
      }
    }
  })
}

